#include "ColorMap.h"
#include <assert.h>
#include <stdio.h>

void printColor(Color* color) {
	printf("%d, %d, %d\n", color->red, color->green, color->blue);
}

void testColorMap() {
	ColorMap* colorMap = createColorMap();
	colorMap->addRedPoint(0, 0);
	colorMap->addRedPoint(100, 1023);

	colorMap->addGreenPoint(0, 0);
	colorMap->addGreenPoint(50, 256);
	colorMap->addGreenPoint(100, 1023);

	colorMap->addBluePoint(0, 1023);
	colorMap->addBluePoint(25, 0);
	colorMap->addBluePoint(75, 1023);
	colorMap->addBluePoint(100, 0);

	Color* color = colorMap->getColorForValue(0);
	printColor(color);

	color = colorMap->getColorForValue(10);
	printColor(color);

	color = colorMap->getColorForValue(75);
	printColor(color);

	color = colorMap->getColorForValue(90);
	printColor(color);
}

void testInterpolationValueMap() {
	InterpolationValueMap * map = createInterpolationValueMap();

	ValuePoint point1;
	point1.inputValue = 0;
	point1.outputValue = 0;
	map->addPoint(&point1);

	ValuePoint point2;
	point2.inputValue = 10;
	point2.outputValue = 100;
	map->addPoint(&point2);

	ValuePoint point3;
	point3.inputValue = 20;
	point3.outputValue = 500;
	map->addPoint(&point3);

	int out1 = map->mapInputValue(0);
	assert(out1 == 0);

	int out2 = map->mapInputValue(10);
	assert(out2 == 100);

	int out = map->mapInputValue(5);
	assert(out == 50);

	out = map->mapInputValue(20);
	assert(out == 500);

	out = map->mapInputValue(15);
	assert(out == 300);

	out = map->mapInputValue(19);
	assert(out == 460);
}

int main() {
	testInterpolationValueMap();
	testColorMap();
	return 0;
}


